home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
D51_NUSource
/
Source
/
Routines
/
Pool.s
< prev
next >
Wrap
Text File
|
1995-09-27
|
7KB
|
305 lines
***************************************************************************************
* Pooled Memory routines, Assembler versions. *
* Taken from "amiga_lib 40.14 (11/08/93)". *
* *
* All of these routines will use the exec.library routines if OS 3 or above is *
* available. The routines will work with any version of AmigaOS from 1.2 onwards. *
* *
* AsmCreatePool newPool [a0] = (memFlags [d0],puddleSize [d1],threshSize [d2]) *
* AsmDeletePool (poolHeader [a0]) *
* AsmAllocPooled memory [d0] = (poolHeader [a0],memSize [d0]) *
* AsmFreePooled (poolHeader [a0],memory [a1],memSize [d0]) *
* *
* See the autodocs for exec or amiga_lib for information on how they are used. *
* *
* Conversion to source code (with slight additions and adaptations) by *
* Leo Davidson (Pot-Noodle / Gods'Gift Utilities). *
* *
* I have also added routines called Leo#? which are identical, but also do a *
* "Move.l PoolHead(a5),a0" at the start of the routine. *
***************************************************************************************
;Test_Pool_On_OS3 ; Use assembled pool routines, even with OS3?
***************************************************************************************
AsmCreatePool
Move.l (AbsExecBase).w,a6 Execbase MUST be in a6.
IFND Test_Pool_On_OS3
Cmp.w #39,$0014(a6) -.
Bcs.s AsmCreatePool_Routine |- Use OS lib if v39+ available.
Jmp _LVOCreatePool(a6) -'
ENDC
AsmCreatePool_Routine
Sub.l A0,A0
Cmp.l D2,D1
Bcs.s AsmCreatePooled_L1
Move.l D0,-(SP)
MoveQ.l #7,D0
Add.l D0,D1
Not.b D0
And.b D0,D1
Move.l D1,-(SP)
MoveQ.l #0,D1
MoveQ.l #$18,D0
Jsr _LVOAllocMem(a6)
Move.l (SP)+,D1
Move.l (SP)+,A0
Tst.l D0
Beq.s AsmCreatePooled_L2
Exg A0,D0
Move.l A0,8(A0)
Addq.l #4,A0
Clr.l (A0)
Move.l A0,-(A0)
Lea 12(A0),A1
Move.l D0,(A1)+
Move.l D1,(A1)+
Move.l D2,(A1)+
AsmCreatePooled_L1
Move.l A0,D0
AsmCreatePooled_L2
RTS
LeoDeletePool
Move.l PoolHead(a5),a0
AsmDeletePool
Move.l (AbsExecBase).w,a6 Execbase MUST be in a6.
IFND Test_Pool_On_OS3
Cmp.w #39,$0014(a6) -.
Bcs.s AsmDeletePool_Routine |- Use OS lib if v39+ available.
Jmp _LVODeletePool(a6) -'
ENDC
AsmDeletePool_Routine
Move.l A0,D0
Beq.s AsmDeletePool_L1
MoveM.l D2/A2,-(SP)
Move.l (A0),A2
AsmDeletePool_L2
Move.l (A2),D2
Beq.s AsmDeletePool_L3
Move.l A2,A1
Move.l D2,A2
Move.l -(A1),D0
Jsr _LVOFreeMem(a6)
Bra.s AsmDeletePool_L2
AsmDeletePool_L1
RTS
AsmDeletePool_L3
Move.l A2,A1
Subq.l #4,A1
MoveM.l (SP)+,D2/A2
MoveQ.l #$18,D0
Jmp _LVOFreeMem(a6)
LeoAllocPooled
Move.l PoolHead(a5),a0
AsmAllocPooled
Move.l (AbsExecBase).w,a6 Execbase MUST be in a6.
IFND Test_Pool_On_OS3
Cmp.w #39,$0014(a6) -.
Bcs.s AsmAllocPooled_Routine |- Use OS lib if v39+ available.
Jmp _LVOAllocPooled(a6) -'
ENDC
AsmAllocPooled_Routine
Move.l D0,D1
Beq.s AsmAllocPooled_L1
Move.l A0,D0
Beq.s AsmAllocPooled_L1
MoveM.l D2/D3/A2/A3,-(SP)
Move.l D1,D2
Move.l A0,A2
Cmp.l $0014(A2),D2
Bcc.s AsmAllocPooled_L2
AsmAllocPooled_L3
Move.l (A2),D3
AsmAllocPooled_L4
Move.l D3,A3
Move.l (A3),D3
Beq.s AsmAllocPooled_L5
Move.l A3,A0
Tst.l 8(A0)
Beq.s AsmAllocPooled_L5
Move.l D2,D0
Jsr _LVOAllocate(a6)
Tst.l D0
Beq.s AsmAllocPooled_L4
Move.l D0,A0
Move.l 12(A2),D0
BTst #$10,D0
Beq.s AsmAllocPooled_L6
Move.l A0,A1
Move.l D2,D1
Addq.l #7,D1
Lsr.l #3,D1
Subq.l #1,D1
Move.w D1,D0
SWAP D1
MoveQ.l #0,D3
AsmAllocPooled_L7
Move.l D3,(A1)+
Move.l D3,(A1)+
DBra D0,AsmAllocPooled_L7
DBra D1,AsmAllocPooled_L7
AsmAllocPooled_L6
Move.l A0,D0
AsmAllocPooled_L8
MoveM.l (SP)+,D2/D3/A2/A3
AsmAllocPooled_L1
RTS
AsmAllocPooled_L2
Move.l D2,D0
Addq.l #8,D0
Addq.l #4,D0
Move.l 12(A2),D1
Bsr AsmAllocPooled_L9
Tst.l D0
Beq.s AsmAllocPooled_L8
Move.l D0,A1
Move.l A2,A0
Addq.l #4,A0
Move.l 4(A0),D0
Move.l A1,4(A0)
Exg A0,D0
MoveM.l D0/A0,(A1)
Move.l A1,(A0)
Addq.l #8,A1
Clr.l (A1)+
Move.l A1,D0
Bra.s AsmAllocPooled_L8
AsmAllocPooled_L5
Move.l 12(A2),D1
Move.l $0010(A2),D0
Add.l #$00000024,D0
Bsr.s AsmAllocPooled_L9
Tst.l D0
Beq.s AsmAllocPooled_L8
Move.l D0,A3
Move.l D0,A1
Move.l A2,A0
Move.l (A0),D0
Move.l A1,(A0)
MoveM.l D0/A0,(A1)
Move.l D0,A0
Move.l A1,4(A0)
MoveQ.l #10,D0
Move.b D0,8(A3)
Move.b D0,9(A3)
Lea Pool.MSG(PC),A0
Move.l A0,10(A3)
Move.l 12(A2),D1
Move.w D1,14(A3)
Lea $0024(A3),A0
MoveQ.l #7,D1
Not.l D1
Move.l A0,D0
And.l D0,D1
Move.l D1,A0
Move.l $0010(A2),D0
Move.l A0,$0010(A3)
Move.l A0,$0014(A3)
Move.l D0,$001C(A3)
Clr.l (A0)
Move.l D0,4(A0)
Add.l D0,A0
Move.l A0,$0018(A3)
Bra AsmAllocPooled_L3
AsmAllocPooled_L9
Addq.l #4,D0
Move.l D0,-(SP)
Jsr _LVOAllocMem(a6)
Tst.l D0
Beq.s AsmAllocPooled_L10
Move.l D0,A0
Move.l (SP),(A0)+
Move.l A0,D0
AsmAllocPooled_L10
Addq.l #4,SP
RTS
LeoFreePooled
Move.l PoolHead(a5),a0
AsmFreePooled
Move.l (AbsExecBase).w,a6 Execbase MUST be in a6.
IFND Test_Pool_On_OS3
Cmp.w #39,$0014(a6) -.
Bcs.s AsmFreePooled_Routine |- Use OS lib if v39+ available.
Jmp _LVOFreePooled(a6) -'
ENDC
AsmFreePooled_Routine
Move.l A0,D1
Beq.s AsmFreePooled_L1
Move.l A1,D1
Beq.s AsmFreePooled_L1
Cmp.l $0014(A0),D0
Bcc.s AsmFreePooled_L2
Move.l A3,-(SP)
Move.l (A0),D1
AsmFreePooled_L3
Move.l D1,A3
Move.l (A3),D1
Beq.s AsmFreePooled_L4
Tst.l 8(A3)
Beq.s AsmFreePooled_L4
Cmp.l $0014(A3),A1
Bcs.s AsmFreePooled_L3
Cmp.l $0018(A3),A1
Bcc.s AsmFreePooled_L3
Move.l A3,A0
Jsr _LVODeallocate(a6)
Move.l 4(A3),A1
Move.l 4(A1),D1
Beq.s AsmFreePooled_L5
Move.l D1,A0
Move.l A3,(A0)
Move.l A0,4(A3)
Move.l A3,4(A1)
Move.l (A3),A0
Move.l A0,(A1)
Move.l A1,4(A0)
Move.l A1,(A3)
AsmFreePooled_L5
Move.l A3,A1
Move.l (SP)+,A3
Move.l $0020(A1),D0
Add.l $0014(A1),D0
Sub.l $0018(A1),D0
Beq.s AsmFreePooled_L6
AsmFreePooled_L1
RTS
AsmFreePooled_L2
Subq.l #4,A1
Subq.l #8,A1
AsmFreePooled_L6
Move.l A1,D0
Move.l (A1)+,A0
Move.l (A1),A1
Move.l A0,(A1)
Move.l A1,4(A0)
Move.l D0,A1
Move.l -(A1),D0
Jmp _LVOFreeMem(a6)
AsmFreePooled_L4
Move.l (SP)+,A3
Move.l D7,-(SP)
Move.l #$0100000F,D7
Jsr _LVOAlert(a6)
Move.l (SP)+,D7
RTS
Dc.b 0
Pool.MSG
Dc.b 'Pool',0
Even